package com.kele.controller.jump;

import com.kele.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;

/**
 * 创作人 王箫凯
 * Date 2021/6/5
 * Time 17:57
 * 此类转跳的作用为： 在几个别的页面进行转跳，不会进行拦截
 * @author 王箫凯
 */
@Controller
@RequestMapping(value = "/commonAction")
public class EasyController {
    /**
     * @return 欢迎界面
     */
    @RequestMapping(value = "/Welcome")
    public String toWelcomePage(HttpServletRequest request,Model model){
        int code=0;
        if(request.getSession()!=null){
            User user= (User) request.getSession().getAttribute("User");
            //非VIP成员
            if (user.getVip() >=3){
                code=4;
                model.addAttribute("code",code);
                return "index";
            }
            code=1;
            model.addAttribute("code",code);
            return "index";
        }
        model.addAttribute("code",code);
        return "index";
    }

    /**
     * @return 返回到分类页面
     */
    @RequestMapping(value = "/classify",method = RequestMethod.GET)
    public  String toClassifyPage(){

        return "static_resources/templates/classify";
    }

    /**
     *
     * @return 转跳到条款界面
     */
    @RequestMapping(value = "/userTerm")
    public String toTermPage(){
        return "/static_resources/templates/termsOfUse";
    }

}
